home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / newsgroups / misc.20021006-20030409 / 000335_fdc@columbia.edu_Sun Feb 23 14:55:54 EST 2003.msg < prev    next >
Text File  |  2020-01-01  |  5KB  |  104 lines

  1. Article: 14132 of comp.protocols.kermit.misc
  2. Path: newsmaster.cc.columbia.edu!news.columbia.edu!news-not-for-mail
  3. From: fdc@columbia.edu (Frank da Cruz)
  4. Newsgroups: comp.os.linux.misc,comp.protocols.kermit.misc
  5. Subject: Re: ls in ftp client, help needed
  6. Date: 23 Feb 2003 13:07:25 -0500
  7. Organization: Columbia University
  8. Lines: 87
  9. Message-ID: <b3b2kt$h01$1@watsol.cc.columbia.edu>
  10. References: <3e57ce85$1@spamkiller.newsgroups.com>
  11. NNTP-Posting-Host: watsol.cc.columbia.edu
  12. X-Trace: newsmaster.cc.columbia.edu 1046023646 16826 128.59.39.139 (23 Feb 2003 18:07:26 GMT)
  13. X-Complaints-To: postmaster@columbia.edu
  14. NNTP-Posting-Date: 23 Feb 2003 18:07:26 GMT
  15. Xref: newsmaster.cc.columbia.edu comp.os.linux.misc:583862 comp.protocols.kermit.misc:14132
  16.  
  17. In article <3e57ce85$1@spamkiller.newsgroups.com>,
  18. Fredrik Lindstr∩┐╜m <95710594@noone.com> wrote:
  19. : How do I display information about the creation year of a file when using
  20. : the ls (LIST) command?
  21. : LIST -aL shows everything I need except seconds and year.
  22. : --full-time does not work when invoked with LIST command.
  23. As others have pointed out, Unix-based FTP servers just run the external
  24. ls command with its fractured date-time format.  Sometimes you can pass
  25. options to the remote ls program, but only ones that it happens to
  26. understand (thus, as another poster pointed out, it will not understand
  27. "--full-time" if it's not GNU ls).  But there's a larger problem, namely
  28. that remote file timestamps are shown in the server's local time, but
  29. the client has no way of knowing what timezone the server is in.
  30.  
  31. One way to do what you want is to use the Kermit FTP client:
  32.  
  33.   http://www.columbia.edu/kermit/ftpclient.html
  34.  
  35. and write a script to get the file list and then get the modtime of each
  36. file using the FTP MDTM directive (which most servers support).  Here's
  37. an example:
  38.  
  39.   set quiet on                               ; No messages
  40.   set exit warning off                       ; No warnings
  41.   .listname := /tmp/list.\v(pid)             ; Temp file name
  42.   ftp open kermit.columbia.edu /anonymous    ; Open FTP connection
  43.   if fail exit 1                             ; Check
  44.   cd kermit/g                                ; CD to disired directory
  45.   if fail exit 1                             ; Check
  46.   mget /namelist:\m(listname) *              ; Get list of names into file
  47.   if fail exit 1                             ; Check
  48.   fopen /read \%c \m(listname)               ; Open name-list file
  49.   if fail exit 1                             ; Check
  50.   while true {                               ; Loop to read each line
  51.       fread /line \%c name                   ; Read a name
  52.       if fail break                          ; Check for EOF
  53.       ftp quote MDTM \m(name)                        ; Get file's modtime
  54.       if fail exit 1 "Server does not support MDTM"  ; Check
  55.       .time := \v(ftp_message)                       ; Save
  56.       ftp size \m(name)                              ; Get file's size
  57.       if fail exit 1 "Server does not support SIZE"  ; Check
  58.       .size := \v(ftp_message)                       ; Save
  59.       echo "\flpad(\m(size),12) \fcvtdate(\m(time)) \m(name)"  ; Show info
  60.   }
  61.   fclose \%c                                 ; Close name-list file
  62.   delete \m(listname)                        ; Delete name-list file
  63.   exit                                       ; BYE to server and exit Kermit
  64.  
  65. The result looks like this:
  66.  
  67.    9018 20020319 23:53:17 ANNOUNCE
  68.   17989 19991227 22:01:15 COPYING
  69.   45127 19991227 22:01:15 README
  70.    4324 20020318 15:26:51 README.68K
  71.   40521 20021030 21:07:37 aavnew.hlp
  72.   18331 20020318 15:27:23 cpm68k.diff
  73.   10202 19991227 22:01:15 gcmdline.c
  74.   34888 19991227 22:01:15 gkermit.c
  75.    7189 19991227 22:01:15 gkermit.h
  76.   14106 19991227 22:01:15 gkermit.nr
  77.   11743 19991227 22:01:15 gproto.c
  78.    6426 19991227 22:01:15 gproto.w
  79.   29269 19991227 22:01:15 gunixio.c
  80.   30658 20010701 16:30:58 gunixio_os2.c
  81.   14902 19991227 22:01:15 gwart.c
  82.    3220 19991227 22:01:15 makefile
  83.  
  84. The times shown are UTC (GMT).  As you can see, the size, date, and name
  85. are available programmatically, so you can make decisions based on them,
  86. display them in different formats, etc.
  87.  
  88. For a Kermit tutorial see:
  89.  
  90.   http://www.columbia.edu/kermit/ckututor.html
  91.  
  92. For a Kermit script-writing tutorial, see:
  93.  
  94.   http://www.columbia.edu/kermit/ckscripts.html
  95.  
  96. For a tutorial on FTP scripting, see:
  97.  
  98.   http://www.columbia.edu/kermit/ftpscripts.html
  99.  
  100. - Frank
  101.